package com.ruoyi.lol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lol.domain.LolCounterList;
import com.ruoyi.lol.service.ILolCounterListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 英雄康特Controller
 * 
 * @author ruoyi
 * @date 2025-07-29
 */
@RestController
@RequestMapping("/lol/counterList")
public class LolCounterListController extends BaseController
{
    @Autowired
    private ILolCounterListService lolCounterListService;

    /**
     * 查询英雄康特列表
     */
    @PreAuthorize("@ss.hasPermi('lol:counterList:list')")
    @GetMapping("/list")
    public TableDataInfo list(LolCounterList lolCounterList)
    {
        startPage();
        List<LolCounterList> list = lolCounterListService.selectLolCounterListList(lolCounterList);
        return getDataTable(list);
    }

    /**
     * 导出英雄康特列表
     */
    @PreAuthorize("@ss.hasPermi('lol:counterList:export')")
    @Log(title = "英雄康特", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LolCounterList lolCounterList)
    {
        List<LolCounterList> list = lolCounterListService.selectLolCounterListList(lolCounterList);
        ExcelUtil<LolCounterList> util = new ExcelUtil<LolCounterList>(LolCounterList.class);
        util.exportExcel(response, list, "英雄康特数据");
    }

    /**
     * 获取英雄康特详细信息
     */
    @PreAuthorize("@ss.hasPermi('lol:counterList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lolCounterListService.selectLolCounterListById(id));
    }

    /**
     * 新增英雄康特
     */
    @PreAuthorize("@ss.hasPermi('lol:counterList:add')")
    @Log(title = "英雄康特", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LolCounterList lolCounterList)
    {
        return toAjax(lolCounterListService.insertLolCounterList(lolCounterList));
    }

    /**
     * 修改英雄康特
     */
    @PreAuthorize("@ss.hasPermi('lol:counterList:edit')")
    @Log(title = "英雄康特", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LolCounterList lolCounterList)
    {
        return toAjax(lolCounterListService.updateLolCounterList(lolCounterList));
    }

    /**
     * 删除英雄康特
     */
    @PreAuthorize("@ss.hasPermi('lol:counterList:remove')")
    @Log(title = "英雄康特", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lolCounterListService.deleteLolCounterListByIds(ids));
    }
}
